//*** Guidance generated code ***//
using System;
using System.Collections.Generic;

using System.Linq;
using NHibernate;
using NHibernate.Criterion;

using ProjectBase.Core;
using ProjectBase.Data;
using ProjectBase.Data.NH;

using $prjsn$.Entity;
using $prjsn$.Common;
using $prjsn$.Common.Data;

namespace $safeprojectname$
{
    public class BusinessObjectTypeDao : BaseDao<BusinessObjectType, int, BusinessObjectTypeFilter>, IBusinessObjectTypeDao
    {
        /// <summary>Evaluates all filters and order-by clauses, paging</summary>
        public override IEnumerable<BusinessObjectType> Find(BusinessObjectTypeFilter filter)
        {
            Criteria.Append(Apply(filter));

            return GetListByCriteria(filter);
        }

        protected override IList<ICriterion> Apply(BusinessObjectTypeFilter filter)
        {
            var restrictions = base.Apply(filter);

            // Equal
            restrictions.AddCompare(filter, f => f.IdExact); // Searches for exact ID
            restrictions.AddIn(filter, f => f.IDColl);

            restrictions.AddEqual(filter, f => f.NameExact);
            restrictions.AddEqual(filter, f => f.DisplayNameExact);

            // Like
            restrictions.AddLike(filter, f => f.Name);
            restrictions.AddLike(filter, f => f.DisplayName);
            restrictions.AddLike(filter, f => f.OriginalClassName);
            restrictions.AddLike(filter, f => f.RowLevelSecurity);
            restrictions.AddLike(filter, f => f.RowLevelSecurityEval);

            return restrictions;
        }
    }
}
